Xbasic

FIELD.MEMO_READ_FROM_FILE Function

Syntax

V Memo_Read_From_File(C Filename[,N flags])

Arguments

Filename

A fully qualified file name.

flags

Optional. Default = "" (Overwrite memo). MEMO_APPEND = Appends Filename to the existing memo, rather than overwriting it.

Description

Read the contents of a file into a memo.

Discussion

The .MEMO_READ_FROM_FILE() method transfers the contents of a file to the memo or bitmap field referenced by the object pointer. This function is especially useful for putting Windows Bitmap files (.BMP) into bitmap image fields. Flag is an optional parameter that you can specify in the case of memo fields (not bitmap fields) to append the contents of the file to the existing memo, rather than overwriting it.

This script inserts the selected bitmap file into the Picture field in a new record in the Library table.

dim tbl as P
filename = ui_get_file("Choose Bitmap", "Bitmaps(*.BMP)","","X")
if (filename = "") then
    end
end if
tbl = table.current()
tbl.enter_begin()
    tbl.description = filename
    tbl.picture.memo_read_from_file(filename)
tbl.enter_end(.T.)
parent.resynch()

This script appends the text in the specified file to the end of the existing memo text.

dim tbl as P
filename = ui_get_file("Choose File", "Text files(*.TXT)","","X")
if (filename = "") then
    end
end if
tbl = table.current()
tbl.change_begin()
    tbl.memo.memo_read_from_file(filename, MEMO_APPEND)
tbl.enter_end(.T.)
parent.resynch()

See Also